<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Dubbo 负载均衡策略深度解析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
            border: 2px solid transparent;
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0,0,0,0.1);
            border-color: #667eea;
        }
        
        .text-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            background-clip: text;
        }
        
        .section-title {
            position: relative;
            padding-left: 20px;
        }
        
        .section-title::before {
            content: '';
            position: absolute;
            left: 0;
            top: 50%;
            transform: translateY(-50%);
            width: 4px;
            height: 80%;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .feature-icon {
            width: 60px;
            height: 60px;
            display: flex;
            align-items: center;
            justify-content: center;
            border-radius: 50%;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            font-size: 24px;
            margin-bottom: 20px;
        }
        
        .mermaid {
            background: white;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 10px 30px rgba(0,0,0,0.1);
        }
        
        .drop-cap {
            float: left;
            font-size: 4em;
            line-height: 0.8;
            margin: 0.1em 0.1em 0 0;
            font-weight: 700;
            color: #667eea;
        }
        
        .strategy-badge {
            display: inline-block;
            padding: 4px 12px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border-radius: 20px;
            font-size: 14px;
            font-weight: 500;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6">
            <div class="max-w-4xl mx-auto text-center">
                <h1 class="text-5xl md:text-6xl font-bold mb-6 leading-tight">
                    Dubbo 负载均衡策略
                    <span class="block text-3xl md:text-4xl mt-4 font-light opacity-90">深度解析与实践指南</span>
                </h1>
                <p class="text-xl md:text-2xl font-light opacity-90 leading-relaxed">
                    探索高性能分布式系统的负载均衡艺术
                </p>
                <div class="mt-10 flex justify-center space-x-6">
                    <div class="text-center">
                        <i class="fas fa-network-wired text-3xl mb-2"></i>
                        <p class="text-sm">分布式架构</p>
                    </div>
                    <div class="text-center">
                        <i class="fas fa-balance-scale text-3xl mb-2"></i>
                        <p class="text-sm">负载均衡</p>
                    </div>
                    <div class="text-center">
                        <i class="fas fa-rocket text-3xl mb-2"></i>
                        <p class="text-sm">高性能</p>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Introduction Section -->
    <section class="py-16 bg-white">
        <div class="container mx-auto px-6">
            <div class="max-w-4xl mx-auto">
                <p class="text-lg leading-relaxed text-gray-700">
                    <span class="drop-cap">D</span>ubbo 是一个高性能的 Java RPC 框架，它提供了多种负载均衡策略，用于在分布式系统中实现服务调用的均衡分发。负载均衡策略的选择直接影响到系统的性能、稳定性和服务质量。在对性能要求较高的场景下，可以选择随机或轮询策略；而在处理时间差异较大或并发波动较大的场景下，最少活跃调用数策略可能更为适合。而在分布式缓存和需要请求幂等性的场景中，一致性哈希是更好的选择。
                </p>
            </div>
        </div>
    </section>

    <!-- Visualization Section -->
    <section class="py-16 bg-gray-50">
        <div class="container mx-auto px-6">
            <div class="max-w-6xl mx-auto">
                <h2 class="text-3xl font-bold text-center mb-12 text-gradient">负载均衡策略全景图</h2>
                <div class="mermaid">
                    graph TD
                        A[Dubbo 负载均衡策略] --> B[Random<br/>随机负载均衡]
                        A --> C[RoundRobin<br/>轮询负载均衡]
                        A --> D[LeastActive<br/>最少活跃调用数]
                        A --> E[ConsistentHash<br/>一致性哈希]
                        A --> F[其他策略]
                        
                        B --> B1[简单高效]
                        B --> B2[支持权重]
                        
                        C --> C1[公平分配]
                        C --> C2[顺序轮询]
                        
                        D --> D1[动态感知]
                        D --> D2[实时负载]
                        
                        E --> E1[请求幂等]
                        E --> E2[缓存友好]
                        
                        F --> F1[最短响应时间]
                        F --> F2[优先级策略]
                        
                        style A fill:#667eea,stroke:#764ba2,stroke-width:3px,color:#fff
                        style B fill:#4facfe,stroke:#00f2fe,stroke-width:2px,color:#fff
                        style C fill:#43e97b,stroke:#38f9d7,stroke-width:2px,color:#fff
                        style D fill:#fa709a,stroke:#fee140,stroke-width:2px,color:#fff
                        style E fill:#30cfd0,stroke:#330867,stroke-width:2px,color:#fff
                        style F fill:#a8edea,stroke:#fed6e3,stroke-width:2px,color:#333
                </div>
            </div>
        </div>
    </section>

    <!-- Strategy Details Section -->
    <section class="py-16 bg-white">
        <div class="container mx-auto px-6">
            <div class="max-w-6xl mx-auto">
                <h2 class="text-4xl font-bold text-center mb-16 text-gradient">核心策略详解</h2>
                
                <!-- Random LoadBalance -->
                <div class="mb-16 card-hover bg-white rounded-2xl shadow-lg p-8">
                    <div class="flex items-start">
                        <div class="feature-icon mr-6">
                            <i class="fas fa-random"></i>
                        </div>
                        <div class="flex-1">
                            <h3 class="text-2xl font-bold mb-4 section-title">
                                Random LoadBalance
                                <span class="strategy-badge ml-4">随机负载均衡</span>
                            </h3>
                            
                            <div class="mb-6">
                                <h4 class="text-lg font-semibold text-gray-700 mb-3">
                                    <i class="fas fa-cogs text-purple-600 mr-2"></i>原理
                                </h4>
                                <p class="text-gray-600 leading-relaxed pl-6">
                                    随机负载均衡策略会在可用的服务提供者列表中随机选择一个服务提供者来处理请求。如果设置了权重（Weight），则根据权重值进行加权随机，权重越高，被选中的概率越大。
                                </p>
                            </div>
                            
                            <div class="grid md:grid-cols-2 gap-6 mb-6">
                                <div>
                                    <h4 class="text-lg font-semibold text-green-700 mb-3">
                                        <i class="fas fa-check-circle mr-2"></i>优点
                                    </h4>
                                    <ul class="space-y-2 text-gray-600">
                                        <li class="flex items-start">
                                            <i class="fas fa-chevron-right text-green-500 mr-2 mt-1 text-sm"></i>
                                            <span>实现简单，随机策略能够在不需要过多配置的情况下均衡地分发请求。</span>
                                        </li>
                                        <li class="flex items-start">
                                            <i class="fas fa-chevron-right text-green-500 mr-2 mt-1 text-sm"></i>
                                            <span>在服务提供者数量较多且请求量较大的场景下，随机策略可以有效地分散流量。</span>
                                        </li>
                                    </ul>
                                </div>
                                
                                <div>
                                    <h4 class="text-lg font-semibold text-red-700 mb-3">
                                        <i class="fas fa-times-circle mr-2"></i>缺点
                                    </h4>
                                    <ul class="space-y-2 text-gray-600">
                                        <li class="flex items-start">
                                            <i class="fas fa-chevron-right text-red-500 mr-2 mt-1 text-sm"></i>
                                            <span>由于是随机选择，可能存在短时间内某个服务提供者被频繁选中的情况，导致负载不均衡。</span>
                                        </li>
                                        <li class="flex items-start">
                                            <i class="fas fa-chevron-right text-red-500 mr-2 mt-1 text-sm"></i>
                                            <span>在流量波动较大的情况下，随机策略可能导致瞬时的不稳定性。</span>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                            
                            <div class="bg-purple-50 rounded-lg p-4">
                                <h4 class="text-lg font-semibold text-purple-700 mb-2">
                                    <i class="fas fa-lightbulb mr-2"></i>适用场景
                                </h4>
                                <p class="text-gray-700">适用于服务提供者数量较多且负载较均匀的场景。</p>
                            </div>
                        </div>
                    </div>
                </div>

                <!-- RoundRobin LoadBalance -->
                <div class="mb-16 card-hover bg-white rounded-2xl shadow-lg p-8">
                    <div class="flex items-start">
                        <div class="feature-icon mr-6" style="background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);">
                            <i class="fas fa-sync-alt"></i>
                        </div>
                        <div class="flex-1">
                            <h3 class="text-2xl font-bold mb-4 section-title">
                                RoundRobin LoadBalance
                                <span class="strategy-badge ml-4" style="background: linear-gradient(135deg, #43e97b 0%, #38f9d7 100%);">轮询负载均衡</span>
                            </h3>
                            
                            <div class="mb-6">
                                <h4 class="text-lg font-semibold text-gray-700 mb-3">
                                    <i class="fas fa-cogs text-green-600 mr-2"></i>原理
                                </h4>
                                <p class="text-gray-600 leading-relaxed pl-6">
                                    轮询负载均衡策略会按照顺序逐一循环地选择服务提供者来处理请求，每个服务提供者轮流接收请求。同样，如果设置了权重（Weight），则按照权重的比例进行轮询分配。
                                </p>
                            </div>
                            
                            <div class="grid md:grid-cols-2 gap-6 mb-6">
                                <div>
                                    <h4 class="text-lg font-semibold text-green-700 mb-3">
                                        <i class="fas fa-check-circle mr-2"></i>优点
                                    </h4>
                                    <ul class="space-y-2 text-gray-600">
                                        <li class="flex items-start">
                                            <i class="fas fa-chevron-right text-green-500 mr-2 mt-1 text-sm"></i>